<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>angularJS测试一,双向绑定</title>
		<script type="text/javascript" src="../js/angular.min.js" ></script>
	</head>
	<body >
		<!--定义一个模块-->
		<div ng-app="myapp" ng-controller="myctrl">
			<table align="center" border="1px" width="60%">
				<tr>
					<th>序号</th>
					<th>商品编号</th>
					<th>商品名称</th>
					<th>商品价格</th>
				</tr>
				<tr ng-repeat="product in products">
					<td>{{$index+1}}</td>
					<td>{{product.id}}</td>
					<td>{{product.name}}</td>
					<td>{{product.price}}</td>
				</tr>
			</table>
		</div>
		<script type="text/javascript">
		    //初始化模块n
		    var myapp=angular.module("myapp",[]);
		    //依赖注入，设置$scope域对象
		    myapp.controller("myctrl",["$scope",function($scope){
		    	$scope.products=[
			    	{
			    		id:1001,
			    		name:'苹果',
			    		price:102301
			    	},
			    	{
			    		id:1002,
			    		name:'电脑',
			    		price:999301
			    	}
		    	];
		    }])
		</script>
	</body>
</html>
